package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import easier.recycler.MultiTypeAdapter;
import easier.recycler.TypeViewHolder;
import java.util.ArrayList;
import java.util.List;

public class MainActivity8 extends AppCompatActivity {

    private RecyclerView mRecycler;

    private List< CharSequence > mList = new ArrayList<>();

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity8.class );
        context.startActivity( starter );
    }

    @Override
    protected void onSaveInstanceState( @NonNull Bundle outState ) {

        super.onSaveInstanceState( outState );
    }

    @Override
    protected void onRestoreInstanceState( @NonNull Bundle savedInstanceState ) {

        super.onRestoreInstanceState( savedInstanceState );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main8 );
        initView();
        initViewAction();
    }

    private void initView() {

        mRecycler = (RecyclerView) findViewById( R.id.recycler );
    }

    private void initViewAction() {

        mRecycler.setLayoutManager( new LinearLayoutManager( this ) );
        mRecycler.setAdapter( new MultiTypeAdapter( convert() ) );
    }

    private List< TypeViewHolder > convert() {

        List< TypeViewHolder > result = new ArrayList<>();

        for ( int i = 0; i < 50; i++ ) {
            mList.add( "" + i );
        }

        return result;
    }
}